package radubrehar;

import java.util.ArrayList;
import java.util.List;

public class UserSession {

	private int id;
	private String sessionId;
	private List<UserSessionLink> links;
	
	public void setId(int id){
		this.id = id;
	}
	
	public int getId() {
		return this.id;
	}
	
	public void setSessionId(String sessionId) {
		this.sessionId = sessionId;
	}
	
	public String getSessionId() {
		return this.sessionId;
	}

	public List<UserSessionLink> getLinks() {
		return links;
	}

	public void setLinks(List<UserSessionLink> links) {
		
		for (UserSessionLink link : links) {
			link.setUserSessionId(this.id);
		}
		
		this.links = links;
	}
	
	/**
	 * adds a new link to the user session
	 * It also sets the userSessionId of link to this.id
	 * 
	 * @param link - the UserSessionLink that is just going to be added to the user session object
	 */
	public void addLink(UserSessionLink link) {
		if (this.links == null) {
			this.links = new ArrayList<UserSessionLink>();
		}
		
		link.setUserSessionId(this.id);
		
		this.links.add(link);
	}
}
